| Conditions | 1 |
| Paths | 1 |
| Total Lines | 90 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | describe('Rest Proxy in Model', function() { |
||
| 200 | describe('Rest Proxy in Store', function() { |
||
| 201 | var store = Ext.create('Ext.data.Store', { |
||
| 202 | model: 'Test.TestBundle.Entity.Car', |
||
| 203 | autoLoad: false, |
||
| 204 | proxy: { |
||
| 205 | type: 'rest', |
||
| 206 | url: '/mycars', |
||
| 207 | format: 'json' |
||
| 208 | } |
||
| 209 | }); |
||
| 210 | it('should load all the entity', function() { |
||
| 211 | var runned = false; |
||
| 212 | runs(function() { |
||
| 213 | var car = Ext.create('Test.TestBundle.Entity.Car', { |
||
| 214 | name: 'Ford', |
||
| 215 | plateNumber: 'AA1234', |
||
| 216 | password: 'xx' |
||
| 217 | }); |
||
| 218 | car.save({ |
||
| 219 | callback: function() { |
||
| 220 | store.load({ |
||
| 221 | callback: function() { |
||
| 222 | runned = true; |
||
| 223 | } |
||
| 224 | }); |
||
| 225 | } |
||
| 226 | }); |
||
| 227 | }); |
||
| 228 | waitsFor(function() { |
||
| 229 | return runned; |
||
| 230 | }); |
||
| 231 | runs(function() { |
||
| 232 | expect(store.count()).toBeGreaterThan(0); |
||
| 233 | }) |
||
| 234 | }); |
||
| 235 | it('should remove all entity', function () { |
||
| 236 | var runned = false; |
||
| 237 | runs(function () { |
||
| 238 | store.load({ |
||
| 239 | callback: function() { |
||
| 240 | store.removeAll(); |
||
| 241 | store.sync({ |
||
| 242 | callback: function() { |
||
| 243 | store.load({ |
||
| 244 | callback: function() { |
||
| 245 | runned = true; |
||
| 246 | } |
||
| 247 | }) |
||
| 248 | } |
||
| 249 | }) |
||
| 250 | } |
||
| 251 | }); |
||
| 252 | }); |
||
| 253 | waitsFor(function () { |
||
| 254 | return runned; |
||
| 255 | }); |
||
| 256 | runs(function () { |
||
| 257 | expect(store.count()).toBe(0); |
||
| 258 | }); |
||
| 259 | }); |
||
| 260 | it('should add new entity', function () { |
||
| 261 | var runned = false; |
||
| 262 | runs(function () { |
||
| 263 | store.add([ |
||
| 264 | { |
||
| 265 | name: 'Ford', |
||
| 266 | plateNumber: 'AA1234', |
||
| 267 | password: 'xx' |
||
| 268 | }, |
||
| 269 | { |
||
| 270 | name: 'BMW', |
||
| 271 | plateNumber: 'ZZ54', |
||
| 272 | password: 'xx' |
||
| 273 | } |
||
| 274 | ]); |
||
| 275 | store.sync({ |
||
| 276 | callback: function() { |
||
| 277 | runned = true; |
||
| 278 | } |
||
| 279 | }); |
||
| 280 | }); |
||
| 281 | waitsFor(function () { |
||
| 282 | return runned; |
||
| 283 | }); |
||
| 284 | runs(function () { |
||
| 285 | expect(store.count()).toBe(2); |
||
| 286 | expect(store.getNewRecords().length).toBe(0); |
||
| 287 | }); |
||
| 288 | }); |
||
| 289 | }); |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.